package interview.volatiled;

public class Question1 {

    private  static  boolean   condition=true;


    public static void main(String[] args) {

        new Thread(new Runnable() {
            @Override
            public void run() {
                while(condition){
                   try {
                        Thread.sleep(50);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName());
                }
            }
        }).start();

         new Thread(new Runnable() {
             @Override
             public void run() {

                 try {
                     Thread.sleep(2000);
                 } catch (InterruptedException e) {
                     e.printStackTrace();
                 }
                 condition=false;
                 System.out.println("-------------------------------------------------conditon为false--------------------------------------");
             }
         }).start();
    }
}
